<?php
/**
 *
 * @package
 * @version 1.0.0 
 * @author Olivier ROGER <roger.olivier@gmail.com>
 *       
 */
ini_set('display_errors', 'on');
define("INC_PATH",realpath(dirname(__FILE__)));
set_include_path(INC_PATH.PATH_SEPARATOR.get_include_path());
//Inclusions minimales
require_once "core/Config.php";
require_once 'core/Twig/Autoloader.php';
Config::register();


try{
	$configIni = Config_Ini::getInstance(ROOT_LIB.'config.ini',MODE_CONFIG);
	define('ROOT_PATH',$configIni->root);
}
catch(Util_ExceptionHandler $e){
	echo $e->getError();
}

//Réglage horaire
date_default_timezone_set('Europe/Paris');

//BDD
try{
	$sql = Db_Spdo::getInstance();
	$sql->query('SET CHARACTER SET utf8');
}
catch(Util_ExceptionHandler $e){
	echo $e->getError();
	exit();
}
//Template
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem(ROOT_PATH.'includes/template/');
$twig = new Twig_Environment($loader, array(
  'cache' 		=> false/*ROOT_PATH.'includes/template/cache/'*/,
  'auto_reload'	=> false
));
$view	= array();

//Authentification
$session 				= Session_Session::getInstance('PBSsession');
$auth 					= new Auth_Auth($session);
$auth->userTable 		= 'users';
$auth->userField 		= 'login';
$auth->pwdField  		= 'pass';
$auth->pwdHash			= $configIni->auth->hash;
$auth->autoLogin		= false;
$subFolder 				= $configIni->subfolder;
if(isset($_SESSION['acl']) && !empty($_SESSION['acl']))
	$ACL = unserialize($session->acl);
 ?>